package shuati.jd2023;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author : LdLtd
 * @Date : 2023/10/28
 * @Description:
 */
public class jd02 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n,m;
        n=sc.nextInt();
        m=sc.nextInt();
        int[] a = new int[n];
        int [][] b=new int[m][2];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            b[i][0]=sc.nextInt();
            b[i][1]=sc.nextInt();
        }
        //满减b1从小到大，满减额度c1从大到小
        Arrays.sort(b,((o1, o2) -> {
            if(o1[0]==o2[0]) return o2[1]-o1[1];
            return o1[0]-o2[0];
        }));
        double res=0;
        for (int i = 0; i < n; i++) {
            int index=search(b,a[i]);
            if(a[i]>=b[0][0]) res+=a[i]-b[index][1];
            else res+=a[i];
        }
        System.out.println(res);
    }
    public  static int search(int [][] b,int price){
        int l=0,r=b.length-1,res=-1;
        while (l<=r) {
            int m=l+(r-l)/2;
            if(b[m][0]<=price) {
                res=m;
                l=m+1;
            }
            else {
               r=m-1;
            }
        }
        return res;
    }
}
